import axios from 'axios'

const http = axios.create({
  timeout: 1000 * 30
})

/**
 * 请求拦截器
 */
http.interceptors.request.use(
  config => {
    return config;
  },
  error => {
    return Promise.reject(error)
  });

/**
 * 响应拦截
 */
http.interceptors.response.use(
  res => {
    return res.data;
  },
  error => {
    console.log('%c!<--- 请求失败,错误状态码:' + status + '--->', 'color:red')
    return Promise.reject(error);
  })

export default http;
